package com.monkeyboy.controller;

import com.monkeyboy.common.dto.ResData;
import com.monkeyboy.service.SystemMonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Gavin
 * @date 2020.07.07 12:11
 */
//@PreAuthorize("hasRole('admin')")//权限表示也可以放在这儿，响应的就会作用于该类的所有方法，优先作用于方法上面的
@RestController
public class SystemMonitorController {
    @Autowired
    private SystemMonitorService systemMonitorService;

    //    @PreAuthorize("hasRole('admin1')")，这种方式的权限验证就是通过springsecurity自动去验证
    //这种方式就是自己指定一个bean来处理
    @PreAuthorize("@permissionService.hasPermi('system:monitor:list') and @permissionService.hasRole('admin')")
    @GetMapping("/system/getSystemInfo")
    public ResData getSystemInfo() throws Exception {
        return systemMonitorService.getSystemMonitorInfo();
    }
}
